package model.micro
{
	import model.macro.Fortress;
	import model.micro.projectiles.Projectile;
	import util.Settings;
	
	/**
	 * A larger object created to represent a fortress in a battle.
	 */
	public class MicroFortress extends Attackable
	{
		private var fortress:Fortress;
		
		public function MicroFortress(fortress:Fortress, y:Number = 0)
		{
			super(20, y, Settings.METER * 6, Settings.METER * 8);
			this.fortress = fortress;
		}
		
		/**
		 * @return	remaining number of hit points of the fortress
		 */
		public function getHP():int
		{
			return fortress.hp;
		}
		
		/**
		 * @return	maximum number of hit points of the fortress
		 */
		public function getMaxHP():int
		{
			return fortress.maxHP;
		}
		
		/**
		 * Called when attacked.
		 * @param	damage	The base damage inflicted.
		 */
		override public function attacked(damage:Number):void
		{
			damage = (damage - Settings.getTimeStep())* 0.01;
			fortress.hp -= damage;
		}
		
		override public function onHit(projectile:Projectile):void
		{
			super.onHit(projectile);
			attacked(projectile.getDamage() * 0.01);
		}
	
	}

}